import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Time:20:56
 */
public class demo2 {
    List<List<Integer>> ret;
    List<Integer> path;
    int n,k;
    public List<List<Integer>> combine(int _n, int _k) {
        n=_n;
        k=_k;
        ret = new ArrayList<>();
        path = new ArrayList<>();
        dfs(1);//从1位置开始传
        return ret;
    }
    public void dfs(int start){
        //递归出口
        if(path.size()==k){
            ret.add(new ArrayList<>(path));
            return;
        }
        for(int i =start;i<=n;i++){
            path.add(i);
            dfs(i+1);
            path.remove(path.size()-1);//恢复现场
        }
    }
}
